package com.salim.leetcode.$12;

public class IntegertoRoman {
    String[][] code = {
            {"1000","900","500","400","100","90","50","40","10","9","5","4","1"},
            {"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"}
    };
    public String intToRoman(int num) {
        StringBuilder result = new StringBuilder();
        for(int i=0;i<code[0].length;i++){
            while (num>=Integer.parseInt(code[0][i])){
                result.append(code[1][i]);
                num-=Integer.parseInt(code[0][i]);
            }
        }
        return result.toString();
    }
    public static void main(String[] args){
        String[][] test = {
                {"VI","VIII","IX","XI","XIV","XV","XVIII","XIX","XX","XXX","XL","L", "LX","LXX","LXXX","XC","C",  "CC", "CCC","CD", "D",  "M","MCMXCIV","LVIII"},
                {"6", "8",   "9", "11","14", "15","18",   "19", "20","30", "40","50","60","70", "80",  "90","100","200","300","400","500","1000","1994","58"}};
        IntegertoRoman integertoRoman = new IntegertoRoman();
        for(int i=0;i<test[0].length;i++){
            if(!String.valueOf(integertoRoman.intToRoman(Integer.parseInt(test[1][i]))).equals(test[0][i])){
                System.out.println("序号："+i+" 转化前："+test[1][i]+ " 转化后："+integertoRoman.intToRoman(Integer.parseInt(test[1][i])));
            }
        }
    }
}
